home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / windownt / uupc11ys.zip / LIB / ARPADATE.C < prev    next >
C/C++ Source or Header  |  1992-11-27  |  1KB  |  50 lines

  1. /*
  2.    arpadate - return the current date/time in RFC 822 format
  3.  
  4.    ctime() format 'Mon Nov 21 11:31:54 1983\n\0'
  5.  
  6.    RFC822 format  'Mon, 21 Nov 1983 11:31:54 PST\0' or
  7.    RFC822 format  'Mon, 16 May 1988 02:13:10 -0700\0'
  8. */
  9.  
  10. #include <stdio.h>
  11. #include <time.h>
  12.  
  13. #include "lib.h"
  14. #include "arpadate.h"
  15.  
  16. char *arpadate()
  17. {
  18.    static char adate[40];
  19.    time_t t;
  20.    static time_t save_t = 0;
  21.  
  22. /*--------------------------------------------------------------------*/
  23. /*       Microsoft and Turbo don't agree on timezone (%z or %Z)       */
  24. /*--------------------------------------------------------------------*/
  25.  
  26. #ifdef __TURBOC__
  27.    static char format[] = "%a, %d %b %Y %H:%M:%S %Z";
  28. #else
  29.    static char format[] = "%a, %d %b %Y %H:%M:%S %z";
  30. #endif
  31.  
  32. /*--------------------------------------------------------------------*/
  33. /*     Return previously formatted buffer if time has not changed     */
  34. /*--------------------------------------------------------------------*/
  35.  
  36.    time( &t );
  37.    if ( save_t == t)
  38.       return adate;
  39.  
  40. /*--------------------------------------------------------------------*/
  41. /*                 Format the new time and return it                  */
  42. /*--------------------------------------------------------------------*/
  43.  
  44.    strftime( adate , sizeof( adate ) , format ,  localtime( &t ));
  45.    printmsg(5, "date=%s", adate);
  46.    save_t = t;
  47.    return adate;
  48.  
  49. } /*arpadate*/
  50.